package pages;

import com.ronds.webtest.exception.CommonException;
import lombok.Data;
import org.springframework.stereotype.Component;

import static com.ronds.webtest.util.WebElementUtil.*;

/**
 * Created by zhanghui on 2017/3/22.
 */
@Component
@Data
public class BasePage {

    //用户头像
    private final String xpathEmployeeNameIcon = "//span[contains(@class,'el-dropdown-link')]";
    //每刻报销管理系统名称
    private final String xpathMaycurSystemName = "//i[@ng-click='vm.toggleThin();']/parent::a/span";
    //安全退出标签
    private final String exitTag = "//li[contains(.,'安全退出')]";
    //服务器出错
    private final String xpathServiceErrorTag = "//*[contains(text(),'服务器出错')]";
    //退出的loading
    private final String xpathLoadingTag = "//*[contains(text(),'正在前往登录页面')]";
    //登录的loading
    private final String xpathLoginLoadingTag = "//span[@class='ant-spin-dot ant-spin-dot-spin']";


    public String getXpathServiceErrorTag() {
        return xpathServiceErrorTag;
    }


    public String getXpathEmployeeNameIcon() {
        return xpathEmployeeNameIcon;
    }

    public void clickEmployeeIconAndExit() {
        try {
            mouseOver(xpathEmployeeNameIcon);
            waitAndClick(exitTag);
        } catch (Exception e) {
            try {
                sleep(1);
                mouseOver(xpathEmployeeNameIcon);
                waitAndClick(exitTag);
            } catch (Exception e1) {
                takeErrorScreenshotAll();
                throw new CommonException("安全退出按钮不可见");
            }
        }
    }

}
